unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Grids,
  StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    CheckBox4: TCheckBox;
    Label1: TLabel;
    StringGrid1: TStringGrid;
    StringGrid2: TStringGrid;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
var
  a,z:integer;
  Zufallszahl : integer;
  Stelle:integer;
begin
  a:=0;
  Stelle:=0;

  if CheckBox1.Checked = True Then
  begin
   z:=100;
  end
  else if CheckBox2.Checked = True Then
  begin
   z:=1000;
  end
  else if CheckBox3.Checked = True Then
  begin
   z:=10000;
  end
  else if CheckBox4.Checked = True Then
  begin
   z:=100000;
  end
  else
  begin
    z:=10
  end;
  







while a <= 9 do
  begin
     Zufallszahl := random(z);
     StringGrid1.Cells[Stelle,0]:= inttostr(ZufallsZahl);
     Stelle:= Stelle + 1;
     a := a+1
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  i,j,k: integer;
  x:string;

begin
  for  k:=0 to 8 do
  begin
    StringGrid2.Cells[k,0]:=StringGrid1.Cells[k,0];
    StringGrid2.Cells[k+1,0]:=StringGrid1.Cells[k+1,0];
  end;
  for i := 0 to 9 do
  begin
    for j := 0 to 8 do
    begin
      if StrToInt(StringGrid2.Cells[j,0]) > StrToInt(StringGrid2.Cells[j+1,0]) then
      begin
         x := StringGrid2.Cells[j,0];
         StringGrid2.Cells[j,0]:= StringGrid2.Cells[j+1,0];
         StringGrid2.Cells[j+1,0]:= x;

      end;
    end;
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  close;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
end;

end.